<?php

namespace app\model;

class Settlement extends SettlementBase
{
    protected $type = [
        'amount' => 'float',
        'electricity_total' => 'float'
    ];

    public function scopeSalesman($query)
    {
        $query->where('sales_id', request()->user->id);
    }

    public function sales()
    {
        return $this->belongsTo(Salesman::class);
    }

    public function salesman()
    {
        return $this->belongsTo(Salesman::class, 'sales_id', 'id');
    }

    public function customers()
    {
        return $this->hasMany(SettlementCustomer::class, 'settlement_id', 'id');
    }
}
